/*
 *  VmGroup.cpp
 *  vorpal
 *
 *  Created by Russell Y Webb on 24/08/09.
 */

#include "VmGroup.h"

namespace Vorpal{

	VmGroup &TheGroup(){
		static VmGroup theGroup;
		return theGroup;
	}
	
#if useThreads
	TMutex globalUniqueIdMutex;
#endif
	
	uint GlobalUniqueId(){
		static uint nextId = 0;
#if useThreads
		globalUniqueIdMutex.lock(); // TODO: should be a spin-lock
#endif
		uint result = nextId;
		nextId += 1;
#if useThreads
		globalUniqueIdMutex.unlock();
#endif
		return result;
	}
	
}
